package com.ruoyi.order.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.Vo.ProductVo;
import com.ruoyi.order.mapper.ProductMapper;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.SeasonProductMapper;
import com.ruoyi.order.domain.SeasonProduct;
import com.ruoyi.order.service.ISeasonProductService;
import com.ruoyi.common.core.text.Convert;
import javax.annotation.Resource;

/**
 * 季节推荐Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-02-04
 */
@Service
public class SeasonProductServiceImpl implements ISeasonProductService 
{
    @Resource
    private SeasonProductMapper seasonProductMapper;

    @Resource
    private ProductMapper productMapper;
    /**
     * 查询季节推荐
     * 
     * @param id 季节推荐主键
     * @return 季节推荐
     */
    @Override
    public SeasonProduct selectSeasonProductById(Integer id)
    {
        return seasonProductMapper.selectSeasonProductById(id);
    }

    /**
     * 查询季节推荐列表
     * 
     * @param seasonProduct 季节推荐
     * @return 季节推荐
     */
    @Override
    public List<SeasonProduct> selectSeasonProductList(SeasonProduct seasonProduct)
    {
        return seasonProductMapper.selectSeasonProductList(seasonProduct);
    }

    /**
     * 新增季节推荐
     * 
     * @param seasonProduct 季节推荐
     * @return 结果
     */
    @Override
    public int insertSeasonProduct(SeasonProduct seasonProduct)
    {
        seasonProduct.setCreateTime(DateUtils.getNowDate());
        return seasonProductMapper.insertSeasonProduct(seasonProduct);
    }

    /**
     * 修改季节推荐
     * 
     * @param seasonProduct 季节推荐
     * @return 结果
     */
    @Override
    public int updateSeasonProduct(SeasonProduct seasonProduct)
    {
        seasonProduct.setUpdateTime(DateUtils.getNowDate());
        return seasonProductMapper.updateSeasonProduct(seasonProduct);
    }

    /**
     * 批量删除季节推荐
     * 
     * @param ids 需要删除的季节推荐主键
     * @return 结果
     */
    @Override
    public int deleteSeasonProductByIds(String ids)
    {
        return seasonProductMapper.deleteSeasonProductByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除季节推荐信息
     * 
     * @param id 季节推荐主键
     * @return 结果
     */
    @Override
    public int deleteSeasonProductById(Integer id)
    {
        return seasonProductMapper.deleteSeasonProductById(id);
    }

    @Override
    public List<ProductVo> getSeasonProductPage(String productName) {
        Map<String,Object> map = new HashMap<>();
        map.put("productName" , productName);
        map.put("state" , 0 );
        List<ProductVo> list = seasonProductMapper.getSeasonProductPage(map);
        return list;
    }

    @Override
    public List<ProductVo> getSeasonProductPageList() {

        Map<String,Object> map = new HashMap<>();
        map.put("state" , 0 );
        List<ProductVo> list = seasonProductMapper.getSeasonProductPageList(map);
        return list;
    }
}
